#ifndef ROBOT_INTERFACE_H
#define ROBOT_INTERFACE_H

#include <stdint.h>
#include <string>
#include <vector>
#include <QtPlugin>
#include "robot_states.h"
#include "MY_DEF.hpp"



class RobotInterface
{
public:
    virtual ~RobotInterface()
    {}
    //初始化和机器人通信相关参数
    //tcp是TCP名称
    virtual bool Init(std::string Ip , uint16_t Port ,std::string Tcp = "TCP", uint32_t Boxid = 0 ,uint32_t RobotId = 0) = 0;
    //获取机器人扫描状态 DO0
    virtual bool ReadScanState( bool  & State ) = 0;
    //获取拍照状态 DO1
    virtual bool ReadTakePhotoState( bool & State ) = 0;
    //获取机器人状态
    virtual bool GetRobotState( ROBOTSTATES &State ) = 0;
    //获取路径下标
    virtual bool GetPathIndex( uint32_t &PathIndex ) = 0 ;
    //获取机器人位置，当前位置
    virtual bool GetRobotPos( ROBOTPOS &PosNow ) = 0;
    //将当前位置的欧拉角转为4元素
    virtual bool GetQuaternion( double W , double X, double Y , double Z ) = 0;
    ///
    /// \brief MoveRobotTo
    /// \param TargetPos：目标位置
    /// \param MoveSpeed：移动速度
    /// \param Congestion：阻塞等待完成否，默认为阻塞等待完成
    /// \return 移动机器人到位置
    ///
    virtual bool MoveRobotTo( ROBOTPOS TargetPos ,
                              float MoveSpeed,
                              bool Congestion = true ) =0;
    ///
    /// \brief RobotMovePath：控制机器人按路径移动
    /// \param Path：路径
    /// \param MoveSpeed：移动速度
    /// \param SpeedRatio:J函数速度比例
    /// \param CntR：平滑度
    /// \param Congestion：阻塞等待完成否，默认为阻塞等待完成
    /// \return
    ///
    virtual bool RobotMovePath(std::vector<ROBOTPOS> Path,
                               float MoveSpeed ,
                               double SpeedRatio=0.5,
                               double CntR=10,
                               bool Congestion = true) = 0;
    //修改TCPName
    virtual bool SetTcpName( std::string TcpName ) = 0;
    //获取失败原因
    virtual std::string GetLastError( void ) = 0;
    //清除错误消息
    virtual void ClearError(void) = 0;
    //获取错误码
    virtual int GetErrorCode( void ) = 0;
protected:
    std::string Ip ;
    uint16_t Port;
    std::string TcpName = "TCP";
    uint32_t BoxId = 0 ;
    uint32_t RobotId = 0;
    std::string ErrorStr;
    bool IsInitSuccess = false;
    int ErrorCode;
    uint8_t Rev[9];
};


#define robot_interface_iid "robothansplugin.Plugin.RobotInterface"
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(RobotInterface,robot_interface_iid)
QT_END_NAMESPACE

#endif // ROBOT_INTERFACE_H
